package migrations

import (
	"time"

	"gorm.io/gorm"
)

func init() {
	AddMigration("users", func(tx *gorm.DB) error {
		type User struct {
			Username    string    `gorm:"primaryKey;size:255"`
			Password    string    `gorm:"not null;size:255"`
			Level       int       `gorm:"not null;default:3"` // 默认LevelUser
			Permissions []string  `gorm:"type:json"`
			TenantID    string    `gorm:"index"`
			IsSystem    bool      `gorm:"default:false"`
			CreatedAt   time.Time `gorm:"autoCreateTime"`
			UpdatedAt   time.Time `gorm:"autoUpdateTime"`
		}
		return tx.AutoMigrate(&User{})
	})
}
